Fix/nanopb makefile check#82
Closed
jakubretajczykBD wants to merge 2 commits intoblockydevs:developfrom
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
developSummary / Notes
Two builds + link
The Makefile can build nanopb separately with
-fPIC(without-fropi/-frwpi) and add those.ofiles to the link. Compilation will succeed.Link / loader
Code built with
-fPICrequires a GOT (Global Offset Table); the compiler places it in the.datasection.In Ledger firmware (nanos2),
script.ldrequires the.datasection to be empty (ASSERT), and.datais anyway directed to DISCARD.Result: the linker reports ".data section must be empty", or, if the assertion is disabled, the GOT is discarded and the application crashes at runtime.
GOT cannot be disabled
In GCC/Clang there is no flag like
-fPIC -fno-got. With-fPIC, the GOT is always generated and cannot be turned off by compiler options alone.Conclusion
The Makefile alone is not enough: nanopb cannot be built with
-fPICand linked into this application on nanos2 using only flags, because the firmware model (empty.data, ROPI/RWPI) is incompatible with the GOT.